<?php


namespace Modules\Admin\Http\Controllers\Authorization\User;


use Illuminate\Support\Facades\DB;
use Modules\Common\General\Security\Authorization\Manager;
use Modules\Common\Models\AdminUser;
use Modules\Common\Util\Api;

class Delete
{
    /**
     * @Route(path=/api/admin/authorization/user method=delete)
     */
    public function index()
    {
        Api::validate( ['user_id' => 'integer']);
        DB::transaction(function (){
            $user = AdminUser::find(request('user_id'));
            $user->delete();
            $m = new Manager();
            $m->deleteUserClearly($user->id);
        });
        return Api::success();
    }

}
